<?php

/*
    picopress - A lightweighed online publishing system
    Copyright (C) 2010  Martin Burkert <martin@burkert.de>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
*/

class Level1Cache extends Cache {
      
    public $config;
    public $menu;
    public $level = 1;
    
    public function get_config () {
        return $this->config;
    }
    
    public function get_menu () {
        return $this->menu;    
    }
    
    public function save ($config, $menu) {
    
        $contents = serialize(array('config' => $config, 'menu' => $menu));
        parent::save ($contents);
    
    }

    public function set_node ($node) {
        $this->node = $node;
        
        parent::set_node($node);
        
        if($this->is_available()){
        
            $fcontents = file_get_contents($this->get_cache_file());
            $cache_struct = unserialize($fcontents);
            
            if(isset($cache_struct['config'])) $this->config = $cache_struct['config'];
            else die ('Error: Wrong file format for cache file (Level 1 Cache). Config not found. (Level 1 Cache)');
            
            if(isset($cache_struct['menu'])) $this->menu = $cache_struct['menu'];
            else die ('Error: Wrong file format for cache file. Menu not found. (Level 1 Cache)');            
            
            
        }
        
        
        
    }

    
    
}


?>